package cn.tedu.submarine;

import javax.security.auth.login.CredentialNotFoundException;
import javax.swing.*;

//战舰
public class Battleship extends SeaObject{
    private int life;   //生命

    public Battleship(){
        super(66,26,270,124,50);
        life = 5;
    }
    @Override
    public void step(){
    }

    /** 重写getImage()*/
    @Override
    public ImageIcon getImage(){
        return Images.battleship; //返回战舰图片
    }

    /** 战舰发射深水炸弹--=生成深水炸弹对象*/
    public Bomb shoot(){
        return new Bomb(this.x,this.y);
    }

    /** 战舰左移*/
    public void moveLeft(){
        x -= speed; //x-(向左)
    }
    /** 战舰右移*/
    public void moveRight(){
        x += speed; //x+(向右)
    }
    /** 战舰增命*/
    public void addLife(int life){
        this.life += life; //增命
    }
    /** 战舰减命*/
    public void subtractLife(){
        life--;
    }

    /** 获取战舰命数*/
    public int getLife(){
        return life; //返回命数
    }
}
